/*******************************************************************************
*  file    : main.cpp
*  created : 01.05.2013
*  author  : 
*******************************************************************************/

#include <QCoreApplication>
#include <qlogger.hpp>
#include <QTimer>
#include <QDebug>
#include <cmath>
#include <QTextStream>

QLogger * l = QLoggerEngine::getLogger("core");

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    
    QLoggerConsoleAppender * cons;
    cons = new QLoggerConsoleAppender(LevelAll,stdout,"%d - <%l> - {%c} -- %m - %f:%p:%i%n");
    l->addAppender(cons);

    logInfo(l,QString("Hello World"));
    logInfo(l)  <<QString("Hello World %1").arg("!");
    logDebug(l) << "Debug message";
    logDebug(l) << QString::fromUtf8("Привет Мир !");
    logInfo(l)  <<"Square root of 2 = "<< ::sqrt(2.0);

    logInfo(l) << hex << "0x" << 0xa5a5;

    l->delAppender(cons);
    cons = new QLoggerColorConsoleAppender(LevelAll,stdout,"%d - <%l> - {%c} -- %m - %f:%p:%i%n");
    l->addAppender(cons);
    qDebug() << "-------------------------";
    logDebug(l) << "Hello world!";
    logInfo(l) << "Hello world!";
    logWarn(l) << "Hello world!";
    logError(l) << "Hello world!";
    logCritical(l) << "Hello world!";
    logException(l) << "Hello world!";


    QTimer::singleShot(1500,&a,SLOT(quit()));
    return a.exec();

}
